package com.bolovan.infovaluta.action;

import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.StreamingResolution;
import net.sourceforge.stripes.action.UrlBinding;

import org.apache.log4j.Logger;

import com.bolovan.infovaluta.bean.ExchangeRate;
import com.bolovan.infovaluta.bean.ExchangeRateSeller;
import com.bolovan.infovaluta.util.RateMaps;
import com.bolovan.infovaluta.util.RateUtil;

@UrlBinding("/api/bnr.action")
public class BnrRates extends BaseAction {
	private static final Logger log = Logger
			.getLogger(BnrRates.class.getName());

	@DefaultHandler
	public Resolution bnr() {
		ExchangeRate bnr = RateMaps.bnr;
		if (bnr == null) {
			bnr = RateMaps.parseMap(ExchangeRateSeller.BNR);
		}
		return new StreamingResolution("json", RateUtil.toJsonString(bnr));
	}
}
